import unittest
from alg import Solution

class TestMaxSubArray(unittest.TestCase):
    def setUp(self):
        self.solution = Solution()

    def test_example1(self):
        self.assertEqual(self.solution.maxSubArray([-2,1,-3,4,-1,2,1,-5,4]), 6)

    def test_example2(self):
        self.assertEqual(self.solution.maxSubArray([1]), 1)

    def test_example3(self):
        self.assertEqual(self.solution.maxSubArray([5,4,-1,7,8]), 23)

    def test_all_negative(self):
        self.assertEqual(self.solution.maxSubArray([-1,-2,-3]), -1)

    def test_single_element(self):
        self.assertEqual(self.solution.maxSubArray([-5]), -5)

    def test_mixed(self):
        self.assertEqual(self.solution.maxSubArray([-2, 3, -1, 2]), 4)

if __name__ == '__main__':
    unittest.main()    